<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <title>收藏夹</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1" name="viewport" />
    <link href="css/dropload.css" rel="stylesheet" type="text/css" />
    <link href="css/base.css" rel="stylesheet" type="text/css" />
    <link href="css/button.css" rel="stylesheet" type="text/css" />
    <link href="css/icon.css" rel="stylesheet" type="text/css" />
    <link href="css/focus.css" rel="stylesheet" type="text/css" />
</head>

<body>
    <ul class="nav-bar">
        <li><a href="favorite.html">我收藏的房源</a></li>
        <li class="last"><a class="active" href="javascript:;">我关注的小区</a></li>
    </ul>
    <div class="container">
        <div id="list-dom"></div>
    </div>
    <script id="list" type="text/html">
        {{each list}}
        <div class="title-bar">
            <i class="icon icon-location-gray"></i>
            <span class="title-bar-title">{{ $value.name }}</span>
            <button data-id="{{ $value.neighbourhoods_id }}" class="btn gray cancel">取消关注</button>
            <div class="title-bar-subtitle">距您{{ $value.juli / 1000 }}公里，{{ $value.addr }}</div>
        </div>
        <div class="convient">
            <div class="divider"></div>
        </div>
        {{/each}}
    </script>
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js" type="text/javascript"></script>
    <script src="js/dropload.min.js" type="text/javascript"></script>
    <script src="js/template.js" type="text/javascript"></script>
    <script src="js/base.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function() {
            bee.wxConfig(function() {
                bee.hideAllNonBaseMenuItem();
            }, function(res) {});

            // 页数
            var page = 0;
            // 每页展示5个
            var limit = 5;
            // 房源列表下拉加载更多
            $('.container').dropload({
                scrollArea: window,
                loadDownFn: function(me) {
                    page++;

                    var point = bee.cache('point');

                    bee.request({
                        url: '/Member/Index/follow_list',
                        data: {
                            page: page,
                            lat: point.lat,
                            lng: point.lng,
                            limit: limit,
                        },
                        success: function(result) {
                            if (result.list.length) {
                                bee.template('list', result);
                                $('body').on('click', '.cancel', function() {
                                    var id = $(this).attr('data-id');
                                    bee.request({
                                        url: '/Member/Index/follow',
                                        data: {
                                            type: 2,
                                            neighbourhoods_id: id,
                                        },
                                        success: function(result) {}
                                    });
                                });
                            } else {
                                me.lock();
                                me.noData();
                            }
                            me.resetload();
                        }
                    });
                }
            });
        });
    </script>
</body>

</html>
